package com.limetalks.util;

import java.util.List;
import java.util.UUID;

import javax.persistence.Persistence;

import com.limetalks.dao.StreamDAO;
import com.limetalks.dao.UserDAO;
import com.limetalks.data.Category;
import com.limetalks.data.Comment;
import com.limetalks.data.Stream;
import com.limetalks.data.User;

public class Helper {

	private static StreamDAO streamDao = new StreamDAO(Persistence.createEntityManagerFactory(GlobalStrings.PERSISTENCE_UNIT_NAME));
	private static UserDAO userDao = new UserDAO(Persistence.createEntityManagerFactory(GlobalStrings.PERSISTENCE_UNIT_NAME));
	
	public static String randomString() {
		return UUID.randomUUID().toString();
	}
	
	public static void main(String[] args) {
		System.out.println(randomString());
	}
	
	public static List<Category> getAllCategories() {
		return streamDao.getAllCategories();
	}
	
	public static List<Stream> findStreamsByMaster(User master) {
		return streamDao.findByMaster(master);
	}
	
	public static Stream findStreamById(Integer id) {
		return streamDao.findById(id);
	}
	
	public static User findUserById(Integer id) {
		return userDao.findById(id);
	}
	
	public static List<Comment> findCommentsByStream(Integer streamId) {
		return streamDao.findCommentByStream(streamId);
	}
	
}
